package com.yiwei.hdb.model;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by xsooy-pc on 2017/8/9.
 */

public class DealTypesModel extends ResponseModel implements Parcelable {

    /**
     * notice : 我承诺我是年满18周岁的成年人,具有完全民事行为能力，已知悉借贷风险，并承诺按时还款，若逾期将承担相关责任和费用，并同意以下条款：
     * count : 2
     * user_level_id : 1
     * data : [{"id":1,"name":"7天贷","brief":"产品描述","banner":"banner图片地址","minimum":500,"maximum":500,"services_fee":78.25,"repaytime":7,"repaytime_type":"天","repay_end_time":"1502825544","services_detail":{"fast_audit_fee":"0.00","account_manage_fee":"0.00","interests":"0.00"}}]
     */

    public String notice;
    public int count;
    public int user_level_id;
    public List<DataBean> data;
    public int next_level_point_diff;

    public static class DataBean implements Parcelable {
        /**
         * id : 1
         * name : 7天贷
         * brief : 产品描述
         * banner : banner图片地址
         * minimum : 500
         * maximum : 500
         * services_fee : 78.25
         * repaytime : 7
         * repaytime_type : 天
         * repay_end_time : 1502825544
         * services_detail : {"fast_audit_fee":"0.00","account_manage_fee":"0.00","interests":"0.00"}
         */

        public int id;
        public String name;
        public String brief;
        public String banner;
        public int minimum;
        public int maximum;
        public String protocol_color;
        public double services_fee;
        public int repaytime;
        public String repaytime_type;
        public long repay_end_time;
        public int limit_user_level;
        public ServicesDetailBean services_detail;
        public BroundColor backgroup_colors;
        public ButtonColor button_colors;
        public Protocol protocol;
        public int before_get_manager; // 是否提前收取管理费和利息：0 - 否、1 - 是
        public int borrow_amount;// 借款本金
        public int give_money; // 到账金额
        public int repay_money;//应还金额

        public static class Protocol implements Parcelable {
            public String account_manage_fee;
            public String manage_impose_fee;

            @Override
            public int describeContents() {
                return 0;
            }

            @Override
            public void writeToParcel(Parcel dest, int flags) {
                dest.writeString(this.account_manage_fee);
                dest.writeString(this.manage_impose_fee);
            }

            public Protocol() {
            }

            protected Protocol(Parcel in) {
                this.account_manage_fee = in.readString();
                this.manage_impose_fee = in.readString();
            }

            public static final Creator<Protocol> CREATOR = new Creator<Protocol>() {
                @Override
                public Protocol createFromParcel(Parcel source) {
                    return new Protocol(source);
                }

                @Override
                public Protocol[] newArray(int size) {
                    return new Protocol[size];
                }
            };
        }


        public static class ButtonColor implements Parcelable {
            public String left_top;
            public String right_bottom;

            @Override
            public int describeContents() {
                return 0;
            }

            @Override
            public void writeToParcel(Parcel dest, int flags) {
                dest.writeString(this.left_top);
                dest.writeString(this.right_bottom);
            }

            public ButtonColor() {
            }

            protected ButtonColor(Parcel in) {
                this.left_top = in.readString();
                this.right_bottom = in.readString();
            }

            public static final Creator<ButtonColor> CREATOR = new Creator<ButtonColor>() {
                @Override
                public ButtonColor createFromParcel(Parcel source) {
                    return new ButtonColor(source);
                }

                @Override
                public ButtonColor[] newArray(int size) {
                    return new ButtonColor[size];
                }
            };
        }

        public static class BroundColor implements Parcelable {
            public String left_top;
            public String right_bottom;

            @Override
            public int describeContents() {
                return 0;
            }

            @Override
            public void writeToParcel(Parcel dest, int flags) {
                dest.writeString(this.left_top);
                dest.writeString(this.right_bottom);
            }

            public BroundColor() {
            }

            protected BroundColor(Parcel in) {
                this.left_top = in.readString();
                this.right_bottom = in.readString();
            }

            public static final Creator<BroundColor> CREATOR = new Creator<BroundColor>() {
                @Override
                public BroundColor createFromParcel(Parcel source) {
                    return new BroundColor(source);
                }

                @Override
                public BroundColor[] newArray(int size) {
                    return new BroundColor[size];
                }
            };
        }

        public static class ServicesDetailBean implements Parcelable {
            /**
             * fast_audit_fee : 0.00
             * account_manage_fee : 0.00
             * interests : 0.00
             */

            public String fast_audit_fee;
            public String account_manage_fee;
            public String interests;

            @Override
            public int describeContents() {
                return 0;
            }

            @Override
            public void writeToParcel(Parcel dest, int flags) {
                dest.writeString(this.fast_audit_fee);
                dest.writeString(this.account_manage_fee);
                dest.writeString(this.interests);
            }

            public ServicesDetailBean() {
            }

            protected ServicesDetailBean(Parcel in) {
                this.fast_audit_fee = in.readString();
                this.account_manage_fee = in.readString();
                this.interests = in.readString();
            }

            public static final Creator<ServicesDetailBean> CREATOR = new Creator<ServicesDetailBean>() {
                @Override
                public ServicesDetailBean createFromParcel(Parcel source) {
                    return new ServicesDetailBean(source);
                }

                @Override
                public ServicesDetailBean[] newArray(int size) {
                    return new ServicesDetailBean[size];
                }
            };
        }


        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeInt(this.id);
            dest.writeString(this.name);
            dest.writeString(this.brief);
            dest.writeString(this.banner);
            dest.writeInt(this.minimum);
            dest.writeInt(this.maximum);
            dest.writeString(this.protocol_color);
            dest.writeDouble(this.services_fee);
            dest.writeInt(this.repaytime);
            dest.writeString(this.repaytime_type);
            dest.writeLong(this.repay_end_time);
            dest.writeInt(this.limit_user_level);
            dest.writeParcelable(this.services_detail, flags);
            dest.writeParcelable(this.backgroup_colors, flags);
            dest.writeParcelable(this.button_colors, flags);
            dest.writeParcelable(this.protocol, flags);
            dest.writeInt(this.before_get_manager);
            dest.writeInt(this.borrow_amount);
            dest.writeInt(this.give_money);
            dest.writeInt(this.repay_money);
        }

        public DataBean() {
        }

        protected DataBean(Parcel in) {
            this.id = in.readInt();
            this.name = in.readString();
            this.brief = in.readString();
            this.banner = in.readString();
            this.minimum = in.readInt();
            this.maximum = in.readInt();
            this.protocol_color = in.readString();
            this.services_fee = in.readDouble();
            this.repaytime = in.readInt();
            this.repaytime_type = in.readString();
            this.repay_end_time = in.readLong();
            this.limit_user_level = in.readInt();
            this.services_detail = in.readParcelable(ServicesDetailBean.class.getClassLoader());
            this.backgroup_colors = in.readParcelable(BroundColor.class.getClassLoader());
            this.button_colors = in.readParcelable(ButtonColor.class.getClassLoader());
            this.protocol = in.readParcelable(Protocol.class.getClassLoader());
            this.before_get_manager = in.readInt();
            this.borrow_amount = in.readInt();
            this.give_money = in.readInt();
            this.repay_money = in.readInt();
        }

        public static final Creator<DataBean> CREATOR = new Creator<DataBean>() {
            @Override
            public DataBean createFromParcel(Parcel source) {
                return new DataBean(source);
            }

            @Override
            public DataBean[] newArray(int size) {
                return new DataBean[size];
            }
        };
    }


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.notice);
        dest.writeInt(this.count);
        dest.writeInt(this.user_level_id);
        dest.writeTypedList(this.data);
        dest.writeInt(this.next_level_point_diff);
    }

    public DealTypesModel() {
    }

    protected DealTypesModel(Parcel in) {
        this.notice = in.readString();
        this.count = in.readInt();
        this.user_level_id = in.readInt();
        this.data = in.createTypedArrayList(DataBean.CREATOR);
        this.next_level_point_diff = in.readInt();
    }

    public static final Creator<DealTypesModel> CREATOR = new Creator<DealTypesModel>() {
        @Override
        public DealTypesModel createFromParcel(Parcel source) {
            return new DealTypesModel(source);
        }

        @Override
        public DealTypesModel[] newArray(int size) {
            return new DealTypesModel[size];
        }
    };
}
